<template>
  <div class="container">
    <div class="back">
      <swiper ref="mySwiper" class="swiper" :options="options">
        <swiper-slide v-for="(item,index) in swiperimages" :key="index">
          <div class="bacground">
            <img :src="item" alt="">
          </div>
        </swiper-slide>
      </swiper>
    </div>
    <!-- <div class="front bg2 maskanimation"></div> -->
    <div class="webSiteBox">
      <div class="scrollbar">
        <h1>目录导航2023</h1>
        <div>环境变量{{ BASE_URL  }}{{ BASE_TITLE }}</div>
        <h2>动画练习:</h2>
        <ul>
          <li v-for="(item,index) in routedata.animation" :key="index">
            <Icon class="red-icon" icon="odi:caigou" :inline="true" /><span @click="clickRoute(item.path)">{{item.meta.title}}</span>
          </li>
        </ul>
        <h2>html使用练习：</h2>
        <ul>
          <li v-for="(item,index) in routedata.html" :key="index">
            <Icon icon="mdi:home" :inline="true" /><span @click="clickRoute(item.path)">{{item.meta.title}}</span>
          </li>
        </ul>
        <h2>一些测试用的Js代码：</h2>
        <ul>
          <li v-for="(item,index) in routedata.JSTest" :key="index">
            <span @click="clickRoute(item.path)">{{item.meta.title}}</span>
          </li>
        </ul>
        <h2>Treejs练习代码:</h2>
        <ul>
          <li v-for="(item,index) in routedata.Three" :key="index">
            <span @click="clickRoute(item.path)">{{item.meta.title}}</span>
          </li>
        </ul>
        <h2>高德地图学习:</h2>
        <ul>
          <li v-for="(item,index) in routedata.Map" :key="index">
            <span @click="clickRoute(item.path)">{{item.meta.title}}</span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  name: 'WorkspaceJsonIndex',
  data() {
    return {
      swiperimages: [
        require('../../assets/homebg/bg01.jpg'),
        require('../../assets/homebg/bg03.jpg'),
      ],
      BASE_URL: process.env.VUE_APP_API_URL,
      BASE_TITLE:  process.env.VUE_APP_TITLE,
      options: {
        loop: true,
        effect: 'fade',
        autoplay: {
          //swiper手动滑动之后自动轮播失效的解决方法,包括触碰，拖动，点击pagination,重新启动自动播放
          disableOnInteraction: false,
          // 自动播放时间：毫秒
          delay: 1000 * 10,
        },
        pagination: {
          el: ".swiper-pagination",
          clickable: true,
          // bulletClass: "my-bullet",
        },
      },
      routedata: {
        animation: [],
        html: [],
        JSTest:[],
        Three:[],
        Map:[],
      }
    };
  },

  mounted() {
    let arrRoutes = this.$router.options.routes;
    console.log(arrRoutes)
    arrRoutes.forEach((item) => {
      if (item.meta.type == 'animation') {
        this.routedata.animation.push(item)
      } else if (item.meta.type == 'researh') {
        this.routedata.html.push(item)
      }else if (item.meta.type == 'JSTest') {
        this.routedata.JSTest.push(item)
      }else if (item.meta.type == 'Threejs') {
        this.routedata.Three.push(item)
      }else if (item.meta.type == 'Map') {
        this.routedata.Map.push(item)
      }
    })
    console.log(this.routedata)
  },

  methods: {
    clickRoute(path) {
      this.$router.push(
        {
          path: path,
          query: {
            // t:Date.now(),
          },
        }
      );
    }
  },
};
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  position: relative;
  display: flex;
  h1{
    font-size: 30px;
  } 
  h2{
    font-size: 20px;
  }
  .webSiteBox {
    width: 90%;
    height: 90%;
    margin: 0 auto;
    padding: 0 3px 0 20px;
    background-color: rgba(25, 25, 25, 0.6);
    border-radius: 10px;
    align-self: center;
    z-index: 4;
    color: #fff;
    overflow: hidden;
    ul {
      display: flex;
    }
    li {
      font-size: 18px;
      line-height: 30px;
      cursor: pointer;
      margin: 0 30px;
      &:hover {
        color: aquamarine;
      }
    }
    .scrollbar {
      height: 100%;
      width: 100%;
      overflow: auto;
      // 1、/*滚动条样式*/
      &::-webkit-scrollbar {
        /*滚动条整体样式*/
        width: 10px; /*高宽分别对应横竖滚动条的尺寸*/
        height: 10px;
      }

      &::-webkit-scrollbar-thumb {
        /*滚动条里面小方块*/
        border-radius: 5;
        -webkit-box-shadow: inset 0 0 5px #fafafa;
        background: rgba(0, 0, 0, 0.7);
      }

      &::-webkit-scrollbar-track {
        /*滚动条里面轨道*/
        -webkit-box-shadow: inset 0 0 5px #fafafa;
        border-radius: 0;
        background: #ececec;
      }

      // 2、/*滚动条样式*/
      &::-webkit-scrollbar {
        /*滚动条整体样式*/
        width: 5px; /*高宽分别对应横竖滚动条的尺寸*/
      }
    }
  }
  h1 {
    text-align: center;
  }
  .back {
    position: absolute;
    width: 100%;
    height: 100vh;
    z-index: 1;
    .bacground {
      width: 100%;
      height: 100vh;
      // overflow: hidden;
      // display: flex;
      // justify-content: center;
      img {
        width: 100%;
        height: 100%;
        // 图片适应box的方法。背景background-size也有相关属性
        object-fit: cover;
        //  图片位置,默认center
        object-position: center;
      }
    }
  }
}
</style>